package com.bw.mallshop.mvvm.view.frament;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.bw.common.mvvm.view.BaseFragment;
import com.bw.mallshop.BR;
import com.bw.mallshop.R;
import com.bw.mallshop.databinding.FragmentCarBinding;
import com.bw.mallshop.field.EventAction;
import com.bw.mallshop.mvvm.viewmodel.CarListViewModel;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class CarFragment extends BaseFragment<FragmentCarBinding, CarListViewModel> {
    @Override
    protected int createvariableId() {
        return BR.vm;
    }

    @Override
    public int bindlayout() {
        return R.layout.fragment_car;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
    public void mergeCarList(EventAction action){
        if (action.equals("refresh_car")){
            vm.uploadCarList();
        }
    }
}
